import BuffUtil from '@/BuffUtil';
import BaseUtil from '@/BaseUtil';
import ArrayUtil from '@/ArrayUtil';
import ItemUtil from '@/ItemUtil';
import SelectCommon from 'code/Core/Common/SelectCommon';
export default class Item_部族权杖 {
    static id = 'C005';
    static itemId = FourCC('C005');
    static 名称: string = '部族权杖';
    static 描述: string = '攻击和法强增加了';
    static 图标: string = 'ReplaceableTextures\\CommandButtons\\BTNSentryWard.blp';
    static buffId: string = 'buff_item_buzuquanzhang';
    static buffType: AppBuffType = {
        id: 'buff_item_buzuquanzhang',
        name: Item_部族权杖.名称,
        ubertip: Item_部族权杖.描述,
        art: Item_部族权杖.图标,
        class: '光环',
        dur: 2,
        attribute: {
            attack_p: 0.1,
            法术强度百分比: 0.1,
        },
        targetAttach: 'origin',
        targetArt: 'Abilities\\Spells\\Orc\\WarDrums\\DrumsCasterHeal.mdl',
    };
    static providers: unit[] = [];
    constructor() {
        BuffUtil.registerBuffType(Item_部族权杖.buffType);
        se.onUnitPickupItem(Item_部族权杖.获取物品);
        se.onUnitDropItem(Item_部族权杖.失去物品);
        se.onUnitPawnItem(Item_部族权杖.失去物品);
        se.onUnitSellItem(Item_部族权杖.失去物品);
        BaseUtil.onTimer(0.5, Item_部族权杖.计时器函数);
    }
    static 计时器函数() {
        for (let u of Item_部族权杖.providers) {
            if (!IsUnitAliveBJ(u)) continue;
            let us = SelectCommon.getAllyUnitInRange(u, 600);
            for (let uu of us) {
                BuffUtil.addBuff(uu, Item_部族权杖.buffId, u);
            }
        }
        return true;
    }
    static 失去物品() {
        let item = GetManipulatedItem();
        if (GetItemTypeId(item) != Item_部族权杖.itemId) return;
        let u = GetTriggerUnit();
        BaseUtil.runLater(0.1, () => {
            if (ItemUtil.getItemCountOfTypeFromUnit(u, Item_部族权杖.id) == 0) ArrayUtil.removeElement(Item_部族权杖.providers, u);
        });
    }
    static 获取物品() {
        let item = GetManipulatedItem();
        if (GetItemTypeId(item) != Item_部族权杖.itemId) return;
        if (Item_部族权杖.providers.includes(GetTriggerUnit())) return;
        Item_部族权杖.providers.push(GetTriggerUnit());
    }
}
